﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sharp.DataTransferObject;
using Sharp.Portal.Interface;
using Sharp.WebBooter.Areas.Platform.Models;

namespace Sharp.WebBooter.Areas.Demo
{

    /// <summary>
    /// 安装
    /// </summary>
    public class Install : INavigation
    {
        public Install()
        {
            //IsDevOnly = true;
        }
        /// <summary>
        /// 导航
        /// </summary>
        /// <returns></returns>
        /// <remarks>导航即权限数据</remarks>
        public IList<PermissionDTO> Navigation()
        { 
            var permissionData =
                   new List<PermissionDTO>()
                   {

new PermissionDTO("Demo001", "演示", 2, "", "fa fa-home"){IsShortcut=true},
new PermissionDTO("Demo001001", "控件演示", 0, "/Demo/Default/Control", "fa fa-eye"),
new PermissionDTO("Demo001002", "动态选项卡", 1, "/Demo/Tab/", "fa fa-eye"),
new PermissionDTO("Demo001003", "左树右列表", 2, "/Demo/Layout/", "fa fa-eye"),
new PermissionDTO("Demo001004", "左树右表单", 3, "/Demo/Layout/Index2", "fa fa-eye"),
new PermissionDTO("Demo001005", "工作流演示", 3, "/Demo/Troubleshooting/Index", "fa fa-eye"),
                   };
            permissionData.ForEach(x =>
            {
                x.SystemCode = "Demo";
                x.Id = Guid.Parse($"{x.Code}_{x.SystemCode}_{x.Category}".Md5());
                var parent = permissionData.FirstOrDefault(c =>
                    c.SystemCode == x.SystemCode &&
                    x.Code.StartsWith(c.Code) &&
                    c.Code.Length == x.Code.Length - 3);
                if (parent != null)
                {
                    x.ParentId = parent.Id;
                }
                else
                {
                    x.ParentId = null;
                }
            });
       
            return permissionData;
        }

        public bool IsDevOnly { get; set; }
    }
}